<template>
  <div class="dynamic">
    <div>
      <div v-if="dataList.list">
        截止时间：{{ dataList.list[0].inputTime | dataFMT }}
      </div>
      <div class="data">
        <el-row :gutter="5">
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>{{ confirmed }}</div>
              <div>累计确诊</div>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>{{ suspected }}</div>
              <div>累计疑似</div>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>{{ dead }}</div>
              <div>累计死亡</div>
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="5">
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>{{ cure }}</div>
              <div>累计治愈</div>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>{{ severe }}</div>
              <div>累计重症</div>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>{{ outside }}</div>
              <div>境外输入</div>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <div>
      <div>国内疫情</div>
      <div class="table_data">
        <el-row>
          <el-col :span="4">
            <div class="grid-content bg-purple" style="background-color: #e0e1fd">
              地区
            </div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple-light" style="background-color: #dd837f">
              新增确诊
            </div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple" style="background-color: #f4d3aa">
              新增疑似
            </div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple-light" style="background-color: #fdcccb">
              新增死亡
            </div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple" style="background-color: #c5eab4">
              新增治愈
            </div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple-light" style="background-color: #d2d2d2">
              境外输入
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <div>
      <el-table :data="dataList.list" style="width: 100%" :show-header='false'>
        <el-table-column prop="province" align="center">
        </el-table-column>
        <el-table-column prop="confirmed" align="center">
        </el-table-column>
        <el-table-column prop="suspected" align="center"> </el-table-column>
        <el-table-column prop="dead" align="center"> </el-table-column>
        <el-table-column prop="cure" align="center"> </el-table-column>
        <el-table-column prop="outside" align="center"> </el-table-column>
      </el-table>
    </div>
    <div>
      <div>最新进展</div>
      <div style="background-color:#f8f8f8;padding:10px">
        <div style="margin-bottom:10px;" v-for="(item,index) in article.list" :key="item.id">
          <div class="logo">
            <div></div>
            <div class="new" v-if="index == 0">最 新</div>
            <div>{{item.publishTime | dataFMT}}</div>
          </div>
          <div style="background-color:#fff;padding:10px;border-radius:5px;" class="title_bottom">{{item.title}}
          </div>
        </div>
      </div>
      <el-pagination background layout="prev, pager, next" :total="dataList.total" :page-size='obj.pageSize'
        :current-page='obj.page' @current-change='change_page'></el-pagination>
    </div>
  </div>
</template>

<style scoped>
  .title_bottom {
    border-bottom: 1px dotted underline;
  }

  /* scoped 用来防止不同组件之间的相同类名的样式污染 */
  .logo {
    overflow: hidden;
    margin-bottom: 5px;
  }

  .logo div {
    float: left;
    margin-right: 5px;
  }

  .logo div:first-child {
    height: 10px;
    width: 10px;
    border-radius: 50%;
    background-color: #005dff;
    margin-top: 4px;
  }

  .logo .new {
    background-color: #f43b3b;
    padding: 3px;
    border-radius: 5px;
    font-size: 12px;
    color: #fff;
  }

  .data .grid-content div:first-child {
    color: #ff6900;
    font-weight: 800;
  }

  .data {
    margin-top: 10px;
  }

  .data .grid-content div {
    font-size: 18px;
    height: 40px;
    line-height: 40px;
    text-align: center;
  }

  .table_data .grid-content {
    min-height: 60px;
    font-size: 18px;

    line-height: 60px;
    text-align: center;
  }

  .el-row {
    margin-bottom: 5px;

  }

  .bg-purple-dark {
    background: #99a9bf;
  }

  .bg-purple {
    background: #fbf5ef;
  }

  .bg-purple-light {
    background: #e5e9f2;
  }

  .data .grid-content {
    border-radius: 4px;
    min-height: 100px;
  }

  .table_data .grid-content {
    border-radius: 4px;
    min-height: 60px;
  }

  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }

</style>>

<script>
  import {
    mapActions,
    mapState,
    mapGetters
  } from "vuex";
  export default {
    watch: {
      obj: {
        handler: function () {
 
          this.page_query(this.obj)
          this.page_query_article(this.obj)
        },
        deep: true
      }
    },
    data() {
      return {
        obj: {
          page: 1,
          pageSize: 5,
        },
      };
    },
    created() {
      this.page_query(this.obj);
      this.page_query_article(
        this.obj
      )
    },
    computed: {
      ...mapState("data_list", ["dataList"]),
      ...mapGetters("data_list", [
        "confirmed",
        "suspected",
        "dead",
        "cure",
        "severe",
        "outside",
      ]),
      ...mapState("article", ['article']),
    },
    methods: {
      ...mapActions("data_list", ["page_query"]),
      ...mapActions("article", ["page_query_article"]),
      change_page(val) {
        this.obj.page = val;
      }
    },
  };

</script>
